﻿using System;
using System.Linq;
using System.Reflection;

namespace ntestools.Helpers
{
    public static class MemberHelper
    {
        public static T CreateInstance<T>(Type[] argTypes, params object[] args)
        {
            return (T)typeof (T).GetConstructors(BindingFlags.NonPublic | BindingFlags.Instance)
                .Where(ctor => EqualsHelper.AreEquals(argTypes, ctor.GetParameters().Select(par => par.ParameterType)))
                .First()
                .Invoke(args);
        }
    }
}
